package cn.source.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.system.domain.BuzMemberGrade;
import cn.source.system.service.IBuzMemberGradeService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * 考生当年同位分Controller
 *
 * @author sourcebyte.vip
 * @date 2025-05-11
 */
@RestController
@RequestMapping("/system/buzMemberGrade")
public class BuzMemberGradeController extends BaseController
{
    @Autowired
    private IBuzMemberGradeService buzMemberGradeService;

    /**
     * 查询考生当年同位分列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzMemberGrade:list')")
    @GetMapping("/list")
    public TableDataInfo list(BuzMemberGrade buzMemberGrade)
    {
        startPage();
        List<BuzMemberGrade> list = buzMemberGradeService.selectBuzMemberGradeList(buzMemberGrade);
        return getDataTable(list);
    }

    /**
     * 获取考生当年同位分详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(buzMemberGradeService.selectBuzMemberGradeById(id));
    }

    /**
     * 新增考生当年同位分
     */
    @PreAuthorize("@ss.hasPermi('system:buzMemberGrade:add')")
    @Log(title = "考生当年同位分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BuzMemberGrade buzMemberGrade)
    {
        return toAjax(buzMemberGradeService.insertBuzMemberGrade(buzMemberGrade));
    }

    /**
     * 修改考生当年同位分
     */
    @PreAuthorize("@ss.hasPermi('system:buzMemberGrade:edit')")
    @Log(title = "考生当年同位分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BuzMemberGrade buzMemberGrade)
    {
        return toAjax(buzMemberGradeService.updateBuzMemberGrade(buzMemberGrade));
    }

    /**
     * 删除考生当年同位分
     */
    @PreAuthorize("@ss.hasPermi('system:buzMemberGrade:remove')")
    @Log(title = "考生当年同位分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(buzMemberGradeService.deleteBuzMemberGradeByIds(ids));
    }

    /**
     * 导出考生当年同位分列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzMemberGrade:export')")
    @Log(title = "考生当年同位分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BuzMemberGrade buzMemberGrade)
    {
        List<BuzMemberGrade> list = buzMemberGradeService.selectBuzMemberGradeList(buzMemberGrade);
        ExcelUtil<BuzMemberGrade> util = new ExcelUtil<BuzMemberGrade>(BuzMemberGrade.class);
        util.exportExcel(response, list, "考生当年同位分数据");
    }
}
